package com.sebastian.studies.ch6;

import java.util.Scanner;

public class Excercise_6_2 {

	public static void main(String[] args) {

		Scanner input = new Scanner(System.in);
		System.out.println("Enter some numbers (six): ");
		int[] myArray = new int[6];

		for (int i = 0; i < myArray.length; i++) {
			myArray[i] = input.nextInt();
		}

		for (int i = 0; i < myArray.length; i++) {
			System.out.print(myArray[i] + " ");
		}

		System.out.println("\nMax is: " + checkingMax(myArray) +
				"\nMax occuance is: " + checkingMaxoccurance(myArray));
		
		input.close();
	}

	private static int checkingMax(int[] array) {
		int max = array[0];
		for(int i = 0; i < array.length; i++) {
			if(max < array[i]) 
				max = array[i];
		}
		return max;
	}

	private static int checkingMaxoccurance(int[] array) {
		int max = checkingMax(array);
		int count = 0;
		for(int i = 0; i < array.length; i++) {
			if(max == array[i]) {
				count++;
			}
		}
		return count;
	}

}
